﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Ui
{
    public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }
        //排序，判断
        private void paixu(string[] a)
        {
            //冒泡排序
            for (int i = 0;i<a.Length;i++)
            {
                for (int k = 0; k<a.Length-1-i; k++)
                {
                    if(Convert.ToInt32(a[k]) < Convert.ToInt32(a[k+1]))
                    {
                        string b = a[k];
                        a[k] = a[k + 1];
                        a[k] = b;
                    }
                }
            }
            string msg;
            int hg = 0;
            //判断
            for (int i = 0;i<a.Length;i++)
            {
                switch (Convert.ToInt32(a[i])/10)
                {
                    case 10:
                    case 9:
                        msg = "优秀";
                        hg += 1;
                        break;
                    case 8:
                        msg = "良";
                        hg += 1;
                        break;
                    case 6:
                        msg = "及格";
                        hg += 1;
                        break; 
                    default:
                        msg = "差";
                        break;

                }
                chart1.Series.Add(a[i]);
                int item = 1;
                listBox1.Items.Add("第"+(i+1).ToString()+"名"+a[i]+"评语:"+msg);
                item+=1;
            }
            //输出合格率
            listBox1.Items.Add("合格率:" + Convert.ToString(a.Length / hg));
        }
        private void iconButton1_Click(object sender, EventArgs e)
        {
            string[] vs;
            //按逗号","来分割成数组
            vs = textBox1.Text.Split(',');
            paixu(vs);
        }
    }
}
